home *** CD-ROM | disk | FTP | other *** search
- Path: DMI.USherb.CA!news!rollet
- From: rollet@oriole.DMI.USherb.CA (Romaric Rollet)
- Newsgroups: comp.lang.c++
- Subject: 'delete' dos not work !!!! (for me...)
- Date: 19 Mar 1996 02:55:49 GMT
- Organization: Universite de Sherbrooke
- Distribution: world
- Message-ID: <ROLLET.96Mar18215549@oriole.DMI.USherb.CA>
- NNTP-Posting-Host: oriole.dmi.usherb.ca
-
- In that piece of code...
- delete never free the variable donnee (or don in the second function)...
-
- Image*
- sobel(Image* im)
- {
- Image* res;
- int* donnee= new int[im->w*im->h];
- int index;
- int max = -65535, min = 65535;
-
- for(int i = 0; i < im->w - 1; i++)
- for (int j = 0; j < im->h - 1; j++) {
- index = i + j * im->w;
- donnee[index] = -im->data[index]
- + im->data[index+1]
- - im->data[index+im->w]
- + im->data[index+1+im->w];
- if (donnee[index] > max) max = donnee[index];
- if (donnee[index] < min) min = donnee[index];
- }
-
- return norm(donnee, im->w, im->h, max , min);
-
- }
-
- Image*
- norm(int* don, int w, int h, int M, int m)
- {
- Image* res=new Image(w, h);
-
- for(int i = 0; i < w * h; i++)
- res->data[i] = (((don[i] - m) * 255) / (M - m));
-
- delete don;
-
- return res;
- }
-
- Why ?? (this is about 800Ko allocated for me and what a shame not to free it !!)
-
- Thanxs for your answers..
- Romaric Rollet.
-
-
-